<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>5、找到所有消失的数字</title>
</head>

<body>
  <script>
    var array = function (nums) {
      let res = [];
      for (let i = 1; i < nums.length + 1; i++) {
        if (nums.indexOf(i) == -1) {
          res.push(i);
        }
      }
      return res;
    };
    console.log(array([4, 3, 2, 7, 8, 2, 3, 1]))
  </script>
</body>

</html>